﻿using System;

namespace Delegates
{
    internal class Program
    {
        public static void Main(string[] args)
        {
            Sample s = new Sample();
            MyDelegateType myDelegateType;
            // add method reference to delegate
            myDelegateType = new MyDelegateType(s.Add);
            
            // invoke method using delegate object
            Console.WriteLine(myDelegateType.Invoke(30,40));


            // Multi-Cast Delegates
            DelegateTypeDouble delegateTypeDouble;
            delegateTypeDouble = s.Div;
            delegateTypeDouble += s.multiply;
            
            // invoke both target methods
            delegateTypeDouble.Invoke(40, 8);
            
            
            
            Console.ReadKey();
        }
    }
}